<template>
  <van-cell>
    <!-- 标题区域的插槽 -->
    <template #title>
      <!-- 无图模式 -->
      <div class="title-box" v-if="articlesList.cover.type === 0">
        <!-- 标题 -->
        <span>{{ articlesList.title }}</span>
      </div>

      <!-- 单图模式 -->
      <div class="title-box" v-if="articlesList.cover.type === 1">
        <!-- 标题 -->
        <span>{{ articlesList.title }}</span>
        <!-- 单图 -->
        <!-- <img class="thumb" :src="articlesList.cover.images[0]" lazy-load /> -->
        <img class="thumb" v-lazy="articlesList.cover.images[0]"  />
      </div>

      <!-- 三图模式 -->
      <div class="thumb-box" v-if="articlesList.cover.type > 1">
        <img class="thumb"
        v-for="(url,index) in articlesList.cover.images"
        :key="index"
        v-lazy="url"
         />
        <!-- <img class="thumb"
        v-for="(url,index) in articlesList.cover.images"
        :key="index"
        :src="url"
        lazy-load /> -->
      </div>
    </template>
    <!-- label 区域的插槽 -->
    <template #label>
      <div class="label-box">
        <div>
          <span>作者:{{articlesList.aut_name}}</span>
          <span>{{articlesList.comm_count}}评论</span>
          <span>{{ formatTime(articlesList.pubdate) }}</span>
        </div>
        <!-- 反馈按钮 -->
        <van-icon name="cross" />
      </div>
    </template>
  </van-cell>
</template>

<script>
// 引入时间处理方法
import { timeAgo } from '@/utils'
export default {
  props: {
    articlesList: {
      type: Object,
      default: () => {
      }
    }
  },
  methods: {
    formatTime (time) {
      return timeAgo(time)
    }
  }
}
</script>

<style scoped lang="less">
/* 标题样式 */
.title-box {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* label描述样式 */
.label-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 文章信息span */
.label-box span {
  margin: 0 3px;
  &:first-child {
    margin-left: 0;
  }
}

/* 图片的样式, 矩形黄金比例：0.618 */
.thumb {
  width: 113px;
  height: 70px;
  background-color: #f8f8f8;
  object-fit: cover;
}

/* 三图, 图片容器 */
.thumb-box {
  display: flex;
  justify-content: space-between;
}
</style>
